#pragma once

#include <iostream>
#include <string>
#include <ctime>

class Task{
  private:
    int x;
    int y;
    char op;

  public:
    Task(){}
    Task(int _x, int _y, char _op):x(_x), y(_y),op(_op)     
    {}
    void Run()
    {
      int z = -1;
      switch(op){
        case '+':
          z = x + y;
          break;
        case '-':
          z = x - y;
          break;
        case '*':
          z = x * y;
          break;
        case '/':
          if(y == 0) std::cerr << "div zero error" << std::endl;
          if(y != 0) z = x / y;
          break;
        case '%':
          if(y == 0) std::cerr << "mod zero error" << std::endl;
          if(y != 0)z = x % y;
          break;
        default:
          std::cerr << "op error" << std::endl;
          break;
      }
      //std::cout << "thread:[" << pthread_self() << "] " << x << op << y << "=" << z << std::endl; 
      printf("thread[%p]: %2d %c %2d = %2d\n", (void*)pthread_self(), x, op, y, z);
    }
    ~Task(){}
};
